home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / em-xmkit.zip / EMM18_A.ASM < prev    next >
Assembly Source File  |  1989-11-29  |  9KB  |  145 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM18_A.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   realloc_pages                                           ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function allows an application program to increase ;
  7. ;                     or decrease (reallocate) the number of logical pages    ;
  8. ;                     allocated to an EMM handle.  There are four             ;
  9. ;                     reallocation cases of interest:                         ;
  10. ;                                                                             ;
  11. ;                     1. A reallocation count of zero.  The handle assigned   ;
  12. ;                        to the application remains assigned and is still     ;
  13. ;                        available for use by the application.  The memory    ;
  14. ;                        manager won't reassign the handle to any other       ;
  15. ;                        application.  However, the handle will return to the ;
  16. ;                        memory manager any currently allocated pages.        ;
  17. ;                        The application must invoke the dealloc_pages        ;
  18. ;                        function before returning to DOS.  If it doesn't,    ;
  19. ;                        the handle will remain assigned and no other         ;
  20. ;                        application will be able to use it.                  ;
  21. ;                                                                             ;
  22. ;                     2. A reallocation count equal to the current            ;
  23. ;                        allocation count.  This is not an error; it          ;
  24. ;                        returns a successful status.                         ;
  25. ;                                                                             ;
  26. ;                     3. A reallocation count greater than the current        ;
  27. ;                        allocation count.  The memory manager will attempt   ;
  28. ;                        to add new pages to those pages already allocated to ;
  29. ;                        the specified EMM handle.  The number of new pages   ;
  30. ;                        added is the difference between the reallocation     ;
  31. ;                        count and the current allocation count.  The         ;
  32. ;                        sequence of logical pages allocated to the EMM       ;
  33. ;                        handle remains continuous after this operation.  The ;
  34. ;                        newly allocated pages have logical page numbers      ;
  35. ;                        which begin where the previously allocated pages     ;
  36. ;                        ended, and continue in ascending sequence.           ;
  37. ;                                                                             ;
  38. ;                     4. A reallocation count less than the current           ;
  39. ;                        allocation count.  The memory manager will attempt   ;
  40. ;                        to subtract some of the currently allocated pages    ;
  41. ;                        and return them to the memory manager.  The number   ;
  42. ;                        of old pages subtracted is the difference between    ;
  43. ;                        the current allocation count and the re-allocation   ;
  44. ;                        count.  The pages are subtracted from the end of the ;
  45. ;                        sequence of pages currently allocated to the         ;
  46. ;                        specified EMM handle.  The sequence of logical pages ;
  47. ;                        allocated to the EMM handle remains continuous after ;
  48. ;                        this operation.                                      ;
  49. ;                                                                             ;
  50. ;                     The handle determines what type of logical pages are    ;
  51. ;                     being reallocated.  Logical pages which were originally ;
  52. ;                     allocated with the alloc_pages or alloc_std_pages       ;
  53. ;                     function are called pages and are 16K bytes long.       ;
  54. ;                     Logical pages which were allocated with the             ;
  55. ;                     alloc_raw_pages function are called raw pages and might ;
  56. ;                     not be the same size as pages allocated with the        ;
  57. ;                     alloc_pages or alloc_std_pages functions.               ;
  58. ;                                                                             ;
  59. ;           PASSED:   &pages:                                                 ;
  60. ;                        is a far pointer to the total number of pages this   ;
  61. ;                        handle should have allocated to it after this        ;
  62. ;                        function is invoked.                                 ;
  63. ;                                                                             ;
  64. ;                     handle:                                                 ;
  65. ;                        is an open EMM handle.                               ;
  66. ;                                                                             ;
  67. ;         RETURNED:   status:                                                 ;
  68. ;                        is the status EMM returns from the call.  All other  ;
  69. ;                        returned results are valid only if the status        ;
  70. ;                        returned is zero.  Otherwise they are undefined.     ;
  71. ;                                                                             ;
  72. ;                     pages:                                                  ;
  73. ;                        is the number of pages now allocated to the EMM      ;
  74. ;                        handle after the pages have been added or            ;
  75. ;                        subtracted.  If the status returned is not zero,     ;
  76. ;                        pages is equal to the number of pages allocated to   ;
  77. ;                        the handle prior to the invocation of this function. ;
  78. ;                        This information can be used to verify that the      ;
  79. ;                        request generated the expected results.              ;
  80. ;                                                                             ;
  81. ; C USE CONVENTION:   unsigned int status;                                    ;
  82. ;                     unsigned int pages;                                     ;
  83. ;                     unsigned int handle;                                    ;
  84. ;                                                                             ;
  85. ;                     status = realloc_pages (&pages,                         ;
  86. ;                                             handle);                        ;
  87. ;-----------------------------------------------------------------------------;
  88. .XLIST
  89. PAGE    60,132
  90.  
  91. IFDEF SMALL
  92.    .MODEL SMALL, C
  93. ENDIF
  94. IFDEF MEDIUM
  95.    .MODEL MEDIUM, C
  96. ENDIF
  97. IFDEF LARGE
  98.    .MODEL LARGE, C
  99. ENDIF
  100. IFDEF COMPACT
  101.    .MODEL COMPACT, C
  102. ENDIF
  103. IFDEF HUGE
  104.    .MODEL HUGE, C
  105. ENDIF
  106.  
  107. INCLUDE emmlib.equ
  108. INCLUDE emmlib.str
  109. INCLUDE emmlib.mac
  110. .LIST
  111. .CODE
  112.  
  113. realloc_pages        PROC                                                  \
  114.             ptr_pages:FAR PTR WORD,                                   \
  115.             handle:WORD
  116.  
  117.     ;---------------------------------------------------------------------;
  118.     ;   do;                                                               ;
  119.     ;   .   reallocate the number of pages currently allocated to the     ;
  120.     ;   .   specified handle;                                             ;
  121.     ;---------------------------------------------------------------------;
  122.     MOVE        AH, realloc_fcn
  123.     MOVE        DX, handle
  124.     MOVE        ES:BX, ptr_pages
  125.     MOVE        BX, ES:[BX]
  126.     INT         EMM_int
  127.  
  128.     ;---------------------------------------------------------------------;
  129.     ;   .   pass the number of pages now allocated to the handle back to  ;
  130.     ;   .   the caller;                                                   ;
  131.     ;---------------------------------------------------------------------;
  132.     MOVE        DX, BX
  133.     MOVE        ES:BX, ptr_pages
  134.     MOVE        ES:[BX], DX
  135.  
  136.     ;---------------------------------------------------------------------;
  137.     ;   .   return (EMM status);                                          ;
  138.     ;   end;                                                              ;
  139.     ;---------------------------------------------------------------------;
  140.     RET_EMM_STAT    AH
  141.  
  142. realloc_pages        ENDP
  143.  
  144. END
  145.